WPS Office.apk(点击下载) / amo.java


package defpackage;

import com.baidu.tts.loopj.AsyncHttpResponseHandler;
import defpackage.amr;
import defpackage.ams;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/* renamed from: amo  reason: default package */
public final class amo {
    private static amr aRc = null;
    private static amr aRd = null;
    private static ams aRe = null;
    static Map<String, String> aRf = new HashMap();

    private static synchronized void HQ() {
        synchronized (amo.class) {
            amy cf = cf("qing.wps.cn");
            if (cf == null || cf.ip == null || cf.ip.length() <= 0) {
                amy cd = amn.cd("qing.wps.cn");
                if (cd == null || cd.ip == null || cd.ip.length() <= 0) {
                    amu HP = amn.HP();
                    if (HP == null || HP.aRx == null || HP.aRx.size() <= 0) {
                        aRd = new amr.a("qing.wps.cn");
                    } else {
                        aRd = new amr.b("qing.wps.cn", HP.aRx);
                    }
                } else {
                    aRd = new amr.c("qing.wps.cn", Arrays.asList(cd.ip.split(";")), cd.ttl);
                    a("qing.wps.cn", cd);
                }
            } else {
                aRd = new amr.c("qing.wps.cn", Arrays.asList(cf.ip.split(";")), cf.ttl);
            }
        }
    }

    private static synchronized void HR() {
        synchronized (amo.class) {
            amy cf = cf("account.wps.cn");
            if (cf == null || cf.ip == null || cf.ip.length() <= 0) {
                amy cd = amn.cd("account.wps.cn");
                if (cd == null || cd.ip == null || cd.ip.length() <= 0) {
                    amu HP = amn.HP();
                    if (HP == null || HP.aRx == null || HP.aRx.size() <= 0) {
                        aRc = new amr.a("account.wps.cn");
                    } else {
                        aRc = new amr.b("account.wps.cn", HP.aRx);
                    }
                } else {
                    aRc = new amr.c("account.wps.cn", Arrays.asList(cd.ip.split(";")), cd.ttl);
                    a("account.wps.cn", cd);
                }
            } else {
                aRc = new amr.c("account.wps.cn", Arrays.asList(cf.ip.split(";")), cf.ttl);
            }
        }
    }

    private static synchronized void HS() {
        synchronized (amo.class) {
            amy cf = cf("proxydns.wps.cn");
            if (cf == null || cf.ip == null || cf.ip.length() <= 0) {
                amy cd = amn.cd("http-proxy.wps.cn");
                if (cd == null || cd.ip == null || cd.ip.length() <= 0) {
                    amu HP = amn.HP();
                    if (HP == null || HP.aRx == null || HP.aRx.size() <= 0) {
                        aRe = new ams.a();
                    } else {
                        aRe = new ams.b(HP.aRz);
                    }
                } else {
                    aRe = new ams.c(Arrays.asList(cd.ip.split(";")), cd.ttl);
                    a("proxydns.wps.cn", cd);
                }
            } else {
                aRe = new ams.c(Arrays.asList(cf.ip.split(";")), cf.ttl);
            }
        }
    }

    private static void a(String str, amy amy) {
        File file;
        try {
            if (vqc.fUp().wyr != null) {
                File file2 = new File(vqc.fUp().wyr);
                if (!file2.exists()) {
                    file2.mkdirs();
                }
                file = new File(vqc.fUp().wyr, str);
            } else {
                file = new File(System.getProperty("java.io.tmpdir"), str);
            }
            amy.ttl = (amy.ttl * 1000) + System.currentTimeMillis();
            PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), AsyncHttpResponseHandler.DEFAULT_CHARSET));
            printWriter.println(amy.toString());
            printWriter.close();
        } catch (Exception e) {
        }
    }

    public static synchronized void a(String str, String str2, vrz vrz) {
        synchronized (amo.class) {
            if (vrz.fUK()) {
                if (aRd != null && "qing.wps.cn".equals(str)) {
                    aRd.c(str, str2, "WIFI".equalsIgnoreCase(smb.fdf().getNetworkType()));
                } else if (aRc != null && "account.wps.cn".equals(str)) {
                    aRc.c(str, str2, "WIFI".equalsIgnoreCase(smb.fdf().getNetworkType()));
                } else if (aRe != null && "http-proxy.wps.cn".equals(str)) {
                    aRe.k(str, str2);
                }
            }
        }
    }

    private static amy cf(String str) {
        amy co;
        try {
            File file = vqc.fUp().wyr != null ? new File(vqc.fUp().wyr, str) : new File(System.getProperty("java.io.tmpdir"), str);
            if (!(file.length() <= 0 || (co = amy.co(vxy.BA(file.getPath()))) == null || co.ip == null)) {
                co.ttl = (co.ttl - System.currentTimeMillis()) / 1000;
                if (co.ttl > 0) {
                    return co;
                }
            }
        } catch (Exception e) {
        }
        return null;
    }

    public static synchronized String cg(String str) {
        String str2;
        synchronized (amo.class) {
            if (aRf.containsKey(str)) {
                str2 = aRf.get(str);
            } else {
                try {
                    String[] split = new cdh().eJ("http://119.29.29.29/d?dn=" + str).anB().anF().anK().split(";");
                    if (split.length > 0) {
                        aRf.put(str, split[0]);
                        str2 = split[0];
                    }
                } catch (IOException e) {
                    vrv.Xf("public_yunkit_txdns_request_ip_fail").Xj(e.getMessage()).send();
                }
                str2 = null;
            }
        }
        return str2;
    }

    public static synchronized List<String> d(String str, int i) {
        List<String> asList;
        synchronized (amo.class) {
            if (!vqc.fUp().wyt) {
                asList = Arrays.asList(str);
            } else if ("qing.wps.cn".equals(str)) {
                if (aRd == null || aRd.HV()) {
                    HQ();
                }
                asList = aRd.b(str, i, "WIFI".equalsIgnoreCase(smb.fdf().getNetworkType()));
            } else if ("account.wps.cn".equals(str)) {
                if (aRc == null || aRc.HV()) {
                    HR();
                }
                asList = aRc.b(str, i, "WIFI".equalsIgnoreCase(smb.fdf().getNetworkType()));
            } else if (!"http-proxy.wps.cn".equals(str)) {
                asList = Arrays.asList(str);
            } else if (amw.HX().cn("http-proxy.wps.cn")) {
                if (aRe == null || aRe.HV()) {
                    HS();
                }
                asList = aRe.d(str, i);
            } else {
                asList = new ArrayList<>();
            }
        }
        return asList;
    }

    public static synchronized void j(String str, String str2) {
        synchronized (amo.class) {
            if (aRd != null && "qing.wps.cn".equals(str)) {
                aRd.b(str, str2, "WIFI".equalsIgnoreCase(smb.fdf().getNetworkType()));
            } else if (aRc != null && "account.wps.cn".equals(str)) {
                aRc.b(str, str2, "WIFI".equalsIgnoreCase(smb.fdf().getNetworkType()));
            } else if (aRe != null && "http-proxy.wps.cn".equals(str)) {
                aRe.j(str, str2);
            }
        }
    }
}